package controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Model;
import model.SearchDAO;
import databean.FundBean;

public class GetRecommendAction extends Action {
	private SearchDAO searchDAO;

	public GetRecommendAction(Model model) {
		this.searchDAO = model.getSearchDAO();
	}

	@Override
	public String getName() {
		return "get-recommend.do";
	}

	@Override
	public String perform(HttpServletRequest request,
			HttpServletResponse response) {
		String rs = "<ul id=\"focus\">";
		String query = request.getParameter("q");
        List<FundBean> funds=searchDAO.search(query);
        if(funds!=null){
        	for(FundBean fund:funds){
        		rs+="<li onclick=\"researchFund("+fund.getFundID()+");\">"+fund.getName()+"</li>";
        	}
        }
        rs+="</ul>";
		request.setAttribute("rs", rs);
		return "board.jsp";
	}

}
